<?php
namespace  Home\Controller;
use Think\Controller;

class STSaleController extends LoginBaseController{
	
	public  function  addSale(){
		
		$this->assign("page_name","业务员信息添加");
		$this->display("stsale/addsale");
		
	}
	
	
	public function detailSale(){
		
		$sale_id  = I('sale_id');
		$sale_en = M('sale_user')->where("sale_id='%s'",$sale_id)->find();
		if(empty($sale_en)){
			 
			$error_msg="该业务员信息不存在,请检查";
			redirect(C('AdminConfig.error_info_page').'?type=505&msg=查询失败,'.$error_msg);
			return;
		}else {
			 
			
			$this->assign("sale_info",$sale_en);
			$this->assign("page_name","业务员信息更新");
			$this->display("stsale/detailsale");
		}
		
		
	}
	
public function dealerbelongstosale(){
    	
    	$sale_id = I('sale_id');   	
    	$sale_en = M('sale_user')->where("sale_id='%s'", $sale_id)->find();
    	
    	$sale_name = cookie('login_user_id');
    	$sale_exist= M('sale_user')->where("sale_name='%s'",$sale_name)->find();
    	//判断当前的登录用户是否为业务员
    	if(empty($sale_exist)){
    		
    		$this->assign("is_Business", 0);
    	}else{
    		$this->assign("is_Business", 1);
    	}
    	
    	if(empty($sale_en)){
    		 
    		$error_msg="该业务员不存在,请检查";
    		redirect(C('AdminConfig.error_info_page').'?type=505&msg=查询失败,'.$error_msg);
    		return;
    	}else {
    		 
    		
    		$this->assign("sale_id", $sale_id);
    		$this->assign("page_name","业务员名下所有经销商");
    		$this->display("stsale/dealersbelongstosale");
    	}
    	
    }
	
    
    
    public function dealerinfosearch(){
    	
    	$sale_id = I('sale_id');
    	$sale_en = M('sale_user')->where("sale_id='%s'", $sale_id)->find();
    	 
    	 
    	if(empty($sale_en)){
    		 
    		$error_msg="该业务员不存在,请检查";
    		redirect(C('AdminConfig.error_info_page').'?type=505&msg=查询失败,'.$error_msg);
    		return;
    	}else {
    		 
    	
    		$this->assign("sale_id", $sale_id);
    		$this->display("stsale/dealerinfosearch");
    	}
    	
    	
    	
    	
    	
    }
    
    
    
    
	public function saleInfo(){
		$this->assign("page_name","业务员信息列表");
		$this->display("stsale/saleinfo");
		
	}
	
}